

export class LogCleaner {
    enable: boolean = false
    _console: Console | null = null;
    constructor() {

    }

    public setEnable(status: boolean) {
        this.enable = status

        if (this.enable) {
            this.clear()
        } else {
            this.restore()
        }
    }

    public clear() {
        this._console = window.console

        window.console = {
            log() { },
            dir() { },
            error() { },
            warn() { },
            clear() { },
            debug() { },
            info() { },
        } as any;
    }

    public restore() {
        if (this._console)
            window.console = this._console
    }

    public log(...args: any[]) {
        this._console?.log(args)
    }
}